﻿using System;
using System.Windows;
using System.Windows.Data;

namespace HSS.Xaml.UI.Data
{
	/// <summary>
	/// Converts a NULL value to <see cref="Visibility.Visible"/> and a non-NULL value to <see cref="Visibility.Collapsed"/>
	/// </summary>
	public class NullVisibleValueConverter : IValueConverter
	{
		/// <summary>
		/// Converts a NULL value to <see cref="Visibility.Visible"/> and a non-NULL value to <see cref="Visibility.Collapsed"/>
		/// </summary>
		/// <param name="value">The value.</param>
		/// <param name="targetType">Not used.</param>
		/// <param name="parameter">Not used.</param>
		/// <param name="culture">Not used.</param>
		/// <returns><see cref="Visibility.Visible"/> for a NULL value, and <see cref="Visibility.Collapsed"/> for a non-NULL value.</returns>
		public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			if (null == value)
				return Visibility.Visible;
			else
				return Visibility.Collapsed;
		}
		/// <summary>
		/// Simple returns <see cref="Visibility.Visible"/>.
		/// </summary>
		/// <param name="value"></param>
		/// <param name="targetType"></param>
		/// <param name="parameter"></param>
		/// <param name="culture"></param>
		/// <returns><see cref="Visibility.Visible"/></returns>
		public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			return Visibility.Visible;
		}
	}
}
